package com.midea.ai.air.ui.more;

import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.midea.ai.air.R;
import com.midea.ai.air.common.BaseActivity;
import com.midea.ai.air.common.Constant;
import com.midea.ai.air.ui.more.adapter.MoreSettingBrainpowerSelectRoomAdapter;
import com.midea.ai.air.ui.more.data.FamilyMember;
import com.midea.ai.air.view.ListViewForScrollView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by hww on 2016/4/20.
 * 新建联动-选择房间
 */
public class MoreSettingBrainpowerSelectRoom extends BaseActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_moresettingbrainpowerselectroom);

        init();
    }

    private RelativeLayout bar_Rl;
    private LinearLayout back_left;
    private ListViewForScrollView mListView;
    private List<FamilyMember> mList_Datas = new ArrayList<>();


    private void init() {
        bar_Rl = (RelativeLayout) findViewById(R.id.bar_parent_rl);
        ViewGroup.LayoutParams LP = bar_Rl.getLayoutParams();
        LP.height = Constant.getTopMargin() + getResources().getDimensionPixelSize(R.dimen.height_44dp);
        bar_Rl.setLayoutParams(LP);

        back_left = (LinearLayout) findViewById(R.id.left_relativeLayout_back);
        back_left.setOnClickListener(this);

        mListView = (ListViewForScrollView) findViewById(R.id.more_setting_brainpower_select_room_listView);

        mList_Datas.add(new FamilyMember(R.drawable.more_setting_branpower_31, "我的家"));

        mListView.setAdapter(new MoreSettingBrainpowerSelectRoomAdapter(MoreSettingBrainpowerSelectRoom.this, mList_Datas));

        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                setResult(MoreSettingNewBrainpower.RESULT_SUCCESS);
                MoreSettingBrainpowerSelectRoom.this.finish();
            }
        });
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.left_relativeLayout_back:
                setResult(MoreSettingNewBrainpower.RESULT_FAILED);
                this.finish();
                break;
            default:
                break;
        }
    }

    @Override
    public void onBackPressed() {
        setResult(MoreSettingNewBrainpower.RESULT_FAILED);
        this.finish();
    }
}
